﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using ConsoleApp.Classex;
using System.Diagnostics;

namespace ConsoleApp
{
    public class demo_drawpicture
    {
        /*
         * cardtype --  1 银联白金卡 2 现钞联名卡  3 万事达个人白金卡  4 银行白金卡(定向)
         * truename -- 姓名
         * identitype -- 证件类型
         * identino -- 证件号码         
         * birthday -- 出生年月
         * courtry -- 国籍
         * liveyear -- 居住时间
         * liveprovince -- 居住省
         * livecity -- 居住市
         * livearea -- 居住区
         * liveaddress -- 居住地
         * mobile -- 手机号码
         * email -- 电子邮箱   
         * sex -- 性别 1 man 2 female
         * marry -- 婚姻状态  1 未 2 已 3 其它
         * education -- 1 初中以下 2 高中专 3 大专 4 大学 5 硕士以上      
         * relativesname -- 亲属联系人
         * relativesmobile -- 亲属联系方式
         * relativetype -- 亲属关系 1 配偶 2 子女 3 父母 4 其它
         * nrelativesname -- 非亲属联系人
         * nrelativesmobile -- 非亲属联系方式
         * nrelativetype -- 非亲属关系 5 同事 6 朋友 7 其它
         * companyname 
         * companyprovince
         * companycity
         * companyarea
         * companyaddress
         * companyphone -- 单位电话号码 0571-86551235-256
         * companyindustry  -- 单位行业分类
         * companydepart  -- 单位任职部门
         * companytitle -- 单位岗位
         * companyjobtype -- 职称 1 高级 2 中级 3 初级 4 无职称
         */


        public static void demo()
        {            
            string firstname = "黄";
            string lastname = "谦肆";
            string name = firstname + lastname;

            using (Image image = Image.FromFile("Desert.jpg"))
            {
                using (Graphics g = Graphics.FromImage(image))
                {
                    /// 画线条
                    Pen pen = new Pen(Color.Black);

                    /// 卡类别银联白金
                    g.DrawLine(pen, new PointF(63, 192), new PointF(68, 197));
                    g.DrawLine(pen, new PointF(68, 197), new PointF(73, 187));
                    /// 卡类别现钞联名卡
                    g.DrawLine(pen, new PointF(63, 217), new PointF(68, 222));
                    g.DrawLine(pen, new PointF(68, 222), new PointF(73, 212));
                    /// 卡类别万事达个人白金卡
                    g.DrawLine(pen, new PointF(63, 241), new PointF(68, 247));
                    g.DrawLine(pen, new PointF(68, 247), new PointF(73, 237));
                    /// 卡类别银联白金(定向)
                    g.DrawLine(pen, new PointF(63, 265), new PointF(68, 270));
                    g.DrawLine(pen, new PointF(68, 270), new PointF(73, 260));

                    /// 姓名
                    g.DrawString(name, new Font("宋体", 6), Brushes.Black, new PointF(135, 370));

                    /// 姓拼音
                    int xposition = 130;
                    foreach (var achar in firstname.ToPinYin())
                    {
                        g.DrawString(achar.ToString(), new Font("宋体", 5), Brushes.Black, new PointF(xposition, 400));
                        xposition += 21;
                    }

                    /// 名拼音
                    xposition += 22;
                    foreach (var achar in lastname.ToPinYin())
                    {
                        g.DrawString(achar.ToString(), new Font("宋体", 5), Brushes.Black, new PointF(xposition, 400));
                        xposition += 21;
                    }

                    /// 国籍
                    g.DrawString("中国", new Font("宋体", 6), Brushes.Black, new PointF(110, 445));

                    /// 年
                    g.DrawString("1980", new Font("宋体", 6), Brushes.Black, new PointF(265, 445));

                    /// 月
                    g.DrawString("12", new Font("宋体", 6), Brushes.Black, new PointF(335, 445));

                    /// 日
                    g.DrawString("29", new Font("宋体", 6), Brushes.Black, new PointF(385, 445));
                    
                    /// 身份证
                    g.DrawLine(pen, new PointF(135, 480), new PointF(140, 485));
                    g.DrawLine(pen, new PointF(140, 485), new PointF(145, 475));
                    /// 军官证
                    g.DrawLine(pen, new PointF(247, 480), new PointF(252, 485));
                    g.DrawLine(pen, new PointF(252, 485), new PointF(257, 475));
                    /// 士兵证
                    g.DrawLine(pen, new PointF(365, 480), new PointF(370, 485));
                    g.DrawLine(pen, new PointF(370, 485), new PointF(375, 475));
                    /// 武警证
                    g.DrawLine(pen, new PointF(480, 480), new PointF(485, 485));
                    g.DrawLine(pen, new PointF(485, 485), new PointF(490, 475));

                    /// 港澳通行证
                    g.DrawLine(pen, new PointF(135, 500), new PointF(140, 505));
                    g.DrawLine(pen, new PointF(140, 505), new PointF(145, 495));
                    /// 台湾居民通行证
                    g.DrawLine(pen, new PointF(365, 500), new PointF(370, 505));
                    g.DrawLine(pen, new PointF(370, 505), new PointF(375, 495));

                    /// 护照
                    g.DrawLine(pen, new PointF(135, 522), new PointF(140, 527));
                    g.DrawLine(pen, new PointF(140, 527), new PointF(145, 517));
                    /// 其它
                    g.DrawLine(pen, new PointF(247, 522), new PointF(252, 527));
                    g.DrawLine(pen, new PointF(252, 527), new PointF(257, 517));

                    /// 证件号码
                    string identity = "330725198212285693";
                    xposition = 131;
                    foreach (var achar in identity)
                    {
                        g.DrawString(achar.ToString(), new Font("宋体", 5), Brushes.Black, new PointF(xposition, 550));
                        xposition += 21;
                    }

                    /// 性别男
                    g.DrawLine(pen, new PointF(105, 590), new PointF(110, 595));
                    g.DrawLine(pen, new PointF(110, 595), new PointF(115, 585));
                    /// 性别女
                    g.DrawLine(pen, new PointF(170, 590), new PointF(175, 595));
                    g.DrawLine(pen, new PointF(175, 595), new PointF(180, 585));

                    /// 未婚
                    g.DrawLine(pen, new PointF(320, 590), new PointF(325, 595));
                    g.DrawLine(pen, new PointF(325, 595), new PointF(330, 585));
                    /// 已婚
                    g.DrawLine(pen, new PointF(403, 590), new PointF(408, 595));
                    g.DrawLine(pen, new PointF(408, 595), new PointF(413, 585));
                    /// 其它
                    g.DrawLine(pen, new PointF(480, 590), new PointF(485, 595));
                    g.DrawLine(pen, new PointF(485, 595), new PointF(490, 585));

                    /// 初中
                    g.DrawLine(pen, new PointF(105, 615), new PointF(110, 620));
                    g.DrawLine(pen, new PointF(110, 620), new PointF(115, 610));
                    /// 高中/中专
                    g.DrawLine(pen, new PointF(215, 615), new PointF(220, 620));
                    g.DrawLine(pen, new PointF(220, 620), new PointF(225, 610));
                    /// 大专
                    g.DrawLine(pen, new PointF(320, 615), new PointF(325, 620));
                    g.DrawLine(pen, new PointF(325, 620), new PointF(330, 610));
                    /// 大学
                    g.DrawLine(pen, new PointF(403, 615), new PointF(408, 620));
                    g.DrawLine(pen, new PointF(408, 620), new PointF(413, 610));
                    /// 硕士或以上
                    g.DrawLine(pen, new PointF(480, 615), new PointF(485, 620));
                    g.DrawLine(pen, new PointF(485, 620), new PointF(490, 610));

                    /// 居住省
                    g.DrawString("陕西", new Font("宋体", 5), Brushes.Black, new PointF(145, 640));
                    /// 居住市
                    g.DrawString("西安", new Font("宋体", 5), Brushes.Black, new PointF(220, 640));
                    /// 居住区
                    g.DrawString("长安", new Font("宋体", 5), Brushes.Black, new PointF(300, 640));
                    string liveaddress = "西装潢路无法伟老顽童苛茜要东载波茳茳";
                    if (liveaddress.Length > 15)
                    {
                        string firstlive = liveaddress.Substring(0,15);
                        string secondlive = liveaddress.Substring(15, liveaddress.Length - 15);

                        g.DrawString(firstlive, new Font("宋体", 5), Brushes.Black, new PointF(380, 640));
                        g.DrawString(secondlive, new Font("宋体", 5), Brushes.Black, new PointF(90, 670));
                    }
                    else
                    {
                        g.DrawString(liveaddress, new Font("宋体", 5), Brushes.Black, new PointF(380, 640));
                    }

                    /// 居住时间
                    g.DrawString("1.5", new Font("宋体", 5), Brushes.Black, new PointF(375, 705));

                    /// 手机号码
                    string mobile = "13605802159";
                    xposition = 131;
                    foreach (var achar in mobile)
                    {
                        g.DrawString(achar.ToString(), new Font("宋体", 5), Brushes.Black, new PointF(xposition, 870));
                        xposition += 21;
                    }

                    /// 电子邮箱
                    g.DrawString("******@email.com", new Font("宋体", 5), Brushes.Black, new PointF(135, 900));

                    /// 亲属联系人
                    g.DrawString("******@email.com", new Font("宋体", 5), Brushes.Black, new PointF(115, 1020));
                    xposition = 333;
                    foreach (var achar in mobile)
                    {
                        g.DrawString(achar.ToString(), new Font("宋体", 5), Brushes.Black, new PointF(xposition, 1020));
                        xposition += 21;
                    }
                    /// 亲属配偶
                    g.DrawLine(pen, new PointF(195, 1082), new PointF(200, 1087));
                    g.DrawLine(pen, new PointF(200, 1087), new PointF(205, 1077));
                    /// 亲属子女
                    g.DrawLine(pen, new PointF(298, 1082), new PointF(303, 1087));
                    g.DrawLine(pen, new PointF(303, 1087), new PointF(308, 1077));
                    /// 亲属父母
                    g.DrawLine(pen, new PointF(401, 1082), new PointF(406, 1087));
                    g.DrawLine(pen, new PointF(406, 1087), new PointF(411, 1077));
                    /// 亲属其它
                    g.DrawLine(pen, new PointF(497, 1082), new PointF(502, 1087));
                    g.DrawLine(pen, new PointF(502, 1087), new PointF(507, 1077));

                    /// 非亲属联系人
                    g.DrawString("******@email.com", new Font("宋体", 5), Brushes.Black, new PointF(115, 1135));
                    xposition = 333;
                    foreach (var achar in mobile)
                    {
                        g.DrawString(achar.ToString(), new Font("宋体", 5), Brushes.Black, new PointF(xposition, 1135));
                        xposition += 21;
                    }
                    /// 非亲属同事
                    g.DrawLine(pen, new PointF(193, 1195), new PointF(198, 1200));
                    g.DrawLine(pen, new PointF(198, 1200), new PointF(203, 1190));
                    /// 非亲属朋友
                    g.DrawLine(pen, new PointF(292, 1195), new PointF(297, 1200));
                    g.DrawLine(pen, new PointF(297, 1200), new PointF(303, 1190));
                    /// 非亲属其它
                    g.DrawLine(pen, new PointF(398, 1195), new PointF(403, 1200));
                    g.DrawLine(pen, new PointF(403, 1200), new PointF(408, 1190));

                    /// 通迅地址住宅
                    g.DrawLine(pen, new PointF(700, 1200), new PointF(705, 1205));
                    g.DrawLine(pen, new PointF(705, 1205), new PointF(710, 1195));
                    /// 通迅地址单位
                    g.DrawLine(pen, new PointF(780, 1200), new PointF(785, 1205));
                    g.DrawLine(pen, new PointF(785, 1205), new PointF(790, 1195));

                    /// 单位名称
                    g.DrawString("恩牛网络科技有限公司", new Font("宋体", 5), Brushes.Black, new PointF(720, 100));
                    /// 单位省
                    g.DrawString("陕西", new Font("宋体", 5), Brushes.Black, new PointF(720, 135));
                    /// 单位市
                    g.DrawString("西安", new Font("宋体", 5), Brushes.Black, new PointF(800, 135));
                    /// 单位区
                    g.DrawString("长安", new Font("宋体", 5), Brushes.Black, new PointF(880, 135));
                    string companyaddress = "西装潢路无法伟老顽童苛茜";
                    if (companyaddress.Length > 15)
                    {
                        string firstlive = companyaddress.Substring(0, 15);
                        string secondlive = companyaddress.Substring(15, liveaddress.Length - 15);

                        g.DrawString(firstlive, new Font("宋体", 5), Brushes.Black, new PointF(965, 135));
                        g.DrawString(secondlive, new Font("宋体", 5), Brushes.Black, new PointF(660, 160));
                    }
                    else
                    {
                        g.DrawString(companyaddress, new Font("宋体", 5), Brushes.Black, new PointF(965, 135));
                    }

                    string companyphone = "0571-86551235-256";
                    string[] phonesplit = companyphone.Split(new char[] { '-' });
                    string phonearea = phonesplit[0];
                    string phonenum = phonesplit[1];
                    string phoneexten = "";
                    if (phonesplit.Count() == 3)
                    {
                        phoneexten = phonesplit[2];
                    }
                    /// 单位电话区号
                    g.DrawString(phonearea, new Font("宋体", 5), Brushes.Black, new PointF(750, 220));
                    /// 单位电话号码
                    g.DrawString(phonenum, new Font("宋体", 5), Brushes.Black, new PointF(890, 220));
                    if (!string.IsNullOrWhiteSpace(phoneexten))
                    {
                        g.DrawString(phoneexten, new Font("宋体", 5), Brushes.Black, new PointF(1090, 220));
                    }
                    /// 单位行业分类
                    g.DrawString("IT", new Font("宋体", 5), Brushes.Black, new PointF(710, 370));
                    /// 单位任职部门
                    g.DrawString("Develop", new Font("宋体", 5), Brushes.Black, new PointF(860, 370));
                    /// 单位岗位
                    g.DrawString("TA", new Font("宋体", 5), Brushes.Black, new PointF(1015, 370));

                    /// 单位职称高级
                    g.DrawLine(pen, new PointF(742, 582), new PointF(747, 587));
                    g.DrawLine(pen, new PointF(747, 587), new PointF(752, 577));
                    /// 单位职称中级
                    g.DrawLine(pen, new PointF(852, 582), new PointF(857, 587));
                    g.DrawLine(pen, new PointF(857, 587), new PointF(862, 577));
                    /// 单位职称初级
                    g.DrawLine(pen, new PointF(960, 582), new PointF(965, 587));
                    g.DrawLine(pen, new PointF(965, 587), new PointF(970, 577));
                    /// 单位无职称
                    g.DrawLine(pen, new PointF(1065, 582), new PointF(1070, 587));
                    g.DrawLine(pen, new PointF(1070, 587), new PointF(1075, 577));

                    /// 单位工作年限
                    g.DrawString("3", new Font("宋体", 5), Brushes.Black, new PointF(745, 605));
                    /// 月收入
                    g.DrawString("3", new Font("宋体", 5), Brushes.Black, new PointF(895, 605));

                    /// 签名
                    g.DrawString(name, new Font("宋体", 5), Brushes.Black, new PointF(1355, 780));

                    g.Flush();
                }
                image.Save("Desertxxxx.jpg");
            }

            Process.Start("Desertxxxx.jpg");

            //Console.WriteLine(name.ToPinYin());
            //Console.WriteLine(name.ToFirstPinYin());
        }
    }
}